//
//  Checkbox.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/11/9.
//

import SwiftUI

struct Checkbox: View {
    var isChecked: Bool
    var style: String
    var action: () -> Void
    
    var body: some View {
        Button(action: action) {
            HStack {
                Image(systemName: isChecked ? "checkmark.square" : "square")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .animation(.spring(), value: isChecked)
                Text(style)
                    .font(.system(size: 20, weight: .bold))
            }
            .foregroundStyle(isChecked ? .yellow : .primary)
        }
        .buttonStyle(PlainButtonStyle()) // 防止按钮样式影响复选框样式
        .frame(maxHeight: 25)
    }
}


#Preview {
    Checkbox(isChecked: true, style: "格纹") {}
}
